﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Physis.Client.Models.Configuration {

    public class SecurityAuthorityModel : ConfigurationItemModel {
                
        #region Private Properties

        private Security.SecurityAuthority securityAuthority = null;

        #endregion


        #region Public Properties

        public override Int64 ConfigurationItemId { set { SecurityAuthorityId = value; } }

        public override Core.CoreConfigurationObject ConfigurationItem { get { return securityAuthority; } }


        public Int64 SecurityAuthorityId {

            set {

                securityAuthority = Application.Security.SecurityAuthority (value);

                if (securityAuthority == null) {

                    securityAuthority = new Security.SecurityAuthority (Application);

                }

            }

        }

        public Security.SecurityAuthority SecurityAuthority { get { return securityAuthority; } set { securityAuthority = value; } }

        #endregion 


        #region Constructors

        public SecurityAuthorityModel (Int64 forSecurityAuthorityId) {

            SecurityAuthorityId = forSecurityAuthorityId;

            return;

        }

        public SecurityAuthorityModel (System.Collections.Specialized.NameValueCollection form) {

            UpdateValues (form);

            return;

        }

        #endregion 


        #region Public Methods

        public override void UpdateValues (System.Collections.Specialized.NameValueCollection form) {

            base.UpdateValues (form);


            SecurityAuthority.Domain = Data.Readers.FormReader.StringFromForm (form, "SecurityAuthority.Domain");

            SecurityAuthority.Protocol = Data.Readers.FormReader.StringFromForm (form, "SecurityAuthority.Protocol");

            SecurityAuthority.SecurityAuthorityType = (Security.Enumerations.SecurityAuthorityType)Data.Readers.FormReader.Int32FromForm (form, "SecurityAuthority.SecurityAuthorityType");

            SecurityAuthority.ServerName = Data.Readers.FormReader.StringFromForm (form, "SecurityAuthority.ServerName");


            return;

        }

        #endregion 

    }

}